<?php

namespace App\Http\Controllers\Api;

use App\Enum\CodeEnum;
use App\Services\UserUrgentService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class UserUrgentController extends ApiBaseController
{
    /**
     * 紧急联系人添加或修改
     * @param Request $request
     * @return JsonResponse|void
     */
    public function addEmergencyContact(Request $request)
    {
        try {
            $res = UserUrgentService::addEmergencyContact($request->post());
            return success($res);
        }catch (\Exception $e) {
            return fail(CodeEnum::ERROR, $e->getMessage());
        }
    }

    /**
     * 紧急联系人查询
     * @return JsonResponse|void
     */
    public function getEmergencyContact()
    {
        try {
            $res = UserUrgentService::getEmergencyContact();
            return success($res);
        }catch (\Exception $e) {
            return fail(CodeEnum::ERROR, $e->getMessage());
        }
    }


}
